package com.fei.service;

import com.fei.bean.CommentBean;
import com.fei.bean.UserBean;
import com.fei.mapper.CommentMapper;
import com.fei.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService{

    @Autowired
    CommentMapper commentMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public List<CommentBean> selectOneVideoIdService(int video_id) {
        List<CommentBean> list = commentMapper.selectOneVideoId(video_id);
        if (list != null){
            for(int i = 0;i<list.size();i++){
                UserBean userBean = userMapper.selectOnePhone(list.get(i).getPhone());
                list.get(i).setUsername(userBean.getName());
            }
        }
        return list;
    }

    @Override
    public int deleteOneIdService(int id) {
        return commentMapper.deleteOneId(id);
    }

}
